package com.talent.core.protocol.mqtt.handler;

import com.talent.core.protocol.mqtt.config.Constant;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.AttributeKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ClassName：HeatbeatHandler
 * @Author: hszhou
 * @Date: 2024/12/24 15:39
 * @Description: 心跳时间检测
 */
@ChannelHandler.Sharable
public class HeartbeatEventTriggered extends ChannelInboundHandlerAdapter {

    private static final Logger logger = LoggerFactory.getLogger(HeartbeatEventTriggered.class);
    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {

        if(evt instanceof IdleStateEvent){


            String clientId = ctx.channel().attr(AttributeKey.valueOf(Constant.CLIENT_ID)).get().toString();


            logger.debug("触发心跳事件");

        }
        super.userEventTriggered(ctx, evt);
    }
}
